var a = getApp();

Page({
    data: {
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1,
        tabIndex: 0,
        state_arr: [ "wait", "wait", "success", "fail" ]
    },
    onLoad: function(a) {
        this.getListData();
    },
    initData: function() {
        this.setData({
            page: 1,
            total_page: 0,
            isLoadMore: !0,
            networkLoading: !1
        });
    },
    changeTab: function(a) {
        this.setData({
            tabIndex: a.detail.name
        }), this.getListData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    getListData: function() {
        var t = this;
        this.initData();
        var e = {};
        0 != this.data.tabIndex && (e.state = this.data.tabIndex);
        var i = a.getNetAddresss("plugin.customer-increase.frontend.activity.activityRewardList");
        a._postNetWork({
            url: i,
            data: e,
            success: function(e) {
                var i = e.data;
                if (1 != i.result) return a.tips(i.msg);
                t.data.total_page = i.data.last_page, t.data.total_page || (t.data.total_page = 0), 
                t.setData({
                    listData: i.data.data,
                    networkLoading: !0
                });
            }
        });
    },
    _getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var e = a.getNetAddresss("plugin.customer-increase.frontend.activity.activityRewardList"), i = {
                page: this.data.page
            };
            0 != this.data.tabIndex && (i.state = this.data.tabIndex), a._postNetWork({
                url: e,
                data: i,
                success: function(a) {
                    var e = a.data;
                    if (t.data.isLoadMore = !0, 1 === e.result) {
                        var i = t.data.listData.concat(e.data.data);
                        t.setData({
                            listData: i
                        });
                    } else t.data.page = t.data.page - 1, t.data.isLoadMore = !1;
                }
            });
        }
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});